{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Dot Dash Plot\n",
    "=============\n",
    "This example shows how to make a dot-dash plot presented in Edward Tufte's book\n",
    "Visual Display of Quantitative Information on page 133. This example is based\n",
    "on https://bl.ocks.org/g3o2/bd4362574137061c243a2994ba648fb8.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "import altair as alt\n",
    "alt.data_transformers.enable('json')\n",
    "from vega_datasets import data\n",
    "\n",
    "cars = data.cars()\n",
    "\n",
    "brush = alt.selection(type='interval')\n",
    "\n",
    "tick_axis = alt.Axis(labels=False, domain=False, ticks=False)\n",
    "tick_axis_notitle = alt.Axis(labels=False, domain=False, ticks=False, title='')\n",
    "\n",
    "points = alt.Chart(cars).mark_point().encode(\n",
    "    x=alt.X('Miles_per_Gallon', axis=alt.Axis(title='')),\n",
    "    y=alt.Y('Horsepower', axis=alt.Axis(title='')),\n",
    "    color=alt.condition(brush, 'Origin', alt.value('grey'))\n",
    ").properties(\n",
    "    selection=brush\n",
    ")\n",
    "\n",
    "x_ticks = alt.Chart(cars).mark_tick().encode(\n",
    "    alt.X('Miles_per_Gallon', axis=tick_axis),\n",
    "    alt.Y('Origin', axis=tick_axis_notitle),\n",
    "    color=alt.condition(brush, 'Origin', alt.value('lightgrey'))\n",
    ").properties(\n",
    "    selection=brush\n",
    ")\n",
    "\n",
    "y_ticks = alt.Chart(cars).mark_tick().encode(\n",
    "    alt.X('Origin', axis=tick_axis_notitle),\n",
    "    alt.Y('Horsepower', axis=tick_axis),\n",
    "    color=alt.condition(brush, 'Origin', alt.value('lightgrey'))\n",
    ").properties(\n",
    "    selection=brush\n",
    ")\n",
    "\n",
    "y_ticks | (points & x_ticks)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "env": {},
   "interrupt_mode": "signal",
   "language": "python",
   "metadata": {},
   "name": "python3"
  },
  "language": "python"
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
